<?php
/**
 * @title:系统通用逻辑模型
 * @desc:
 * @since：2019/6/28 0028  下午 3:56
 */
namespace app\common\logic;

use app\model\ModelBase;
use app\common\tools\ReturnCode;

class Base extends ModelBase
{

/*    //protected $request;
    protected $returnCode;

    public function __construct(ReturnCode $returnCode)
    {
        parent::__construct();
        //$this->request = $request;
        $returnCode = $returnCode;
    }*/



    static public function buildSuccess($data = [], $result_code, $msg = '操作成功') {
        $return = [
            'code'=>"SUCCESS",
            'result_code' => $result_code,
            'msg'  => $msg,
            'timestamp'  => time(),
            'nonce'  => rand(11111,99999),
            'data' => $data
        ];


        return json($return);
    }

    static public function buildFailed($err_code, $err_code_des) {
        $return = [
            'code' => "FALL",
            'err_code' => $err_code,
            'msg'  => $err_code_des
        ];

        return json($return);
    }




    protected function debug($data) {
        if ($data) {
            $this->debug[] = $data;
        }
    }

}